package cn.initcap.designpattern.pattern.creational.singleton;

/**
 * 单例模式最佳实践
 * 可以防止序列化攻击和反射攻击
 *
 * @author initcap
 * @date 2018/8/28 AM9:08
 */
public enum EnumInstance {
    INSTANCE {
        @Override
        protected void printTest() {
            System.out.println("Initcap Print Test");
        }
    };

    private Object data;

    public static EnumInstance getInstance() {
        return INSTANCE;
    }

    protected abstract void printTest();

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
